Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf76727d

Browse files
authored
AddnoCheck API option (microsoft#57934)
1 parent95d23ca commitf76727d

File tree

47 files changed

+3674
-7
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+3674
-7
lines changed

‎src/compiler/checker.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8797,6 +8797,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
87978797
}
87988798

87998799
function serializeSymbol(symbol: Symbol, isPrivate: boolean, propertyAsAlias: boolean): void {
8800+
void getPropertiesOfType(getTypeOfSymbol(symbol)); // resolve symbol's type and properties, which should trigger any required merges
88008801
// cache visited list based on merged symbol, since we want to use the unmerged top-level symbol, but
88018802
// still skip reserializing it if we encounter the merged product later on
88028803
const visitedSym = getMergedSymbol(symbol);
@@ -48893,6 +48894,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
4889348894
if (!sym) {
4889448895
return !node.locals ? [] : nodeBuilder.symbolTableToDeclarationStatements(node.locals, node, flags, tracker);
4889548896
}
48897+
resolveExternalModuleSymbol(sym); // ensures cjs export assignment is setup
4889648898
return !sym.exports ? [] : nodeBuilder.symbolTableToDeclarationStatements(sym.exports, node, flags, tracker);
4889748899
},
4889848900
isImportRequiredByAugmentation,

‎src/compiler/commandLineParser.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -772,6 +772,20 @@ const commandOptionsWithoutBuild: CommandLineOption[] = [
772772
defaultValueDescription:false,
773773
description:Diagnostics.Disable_emitting_comments,
774774
},
775+
{
776+
name:"noCheck",
777+
type:"boolean",
778+
showInSimplifiedHelpView:false,
779+
category:Diagnostics.Compiler_Diagnostics,
780+
description:Diagnostics.Disable_full_type_checking_only_critical_parse_and_emit_errors_will_be_reported,
781+
transpileOptionValue:undefined,
782+
defaultValueDescription:false,
783+
affectsSemanticDiagnostics:true,
784+
affectsBuildInfo:true,
785+
extraValidation(){
786+
return[Diagnostics.Unknown_compiler_option_0,"noCheck"];
787+
},
788+
},
775789
{
776790
name:"noEmit",
777791
type:"boolean",

‎src/compiler/diagnosticMessages.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6388,6 +6388,10 @@
63886388
"category":"Message",
63896389
"code":6804
63906390
},
6391+
"Disable full type checking (only critical parse and emit errors will be reported).": {
6392+
"category":"Message",
6393+
"code":6805
6394+
},
63916395

63926396
"one of:": {
63936397
"category":"Message",

‎src/compiler/emitter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -848,8 +848,8 @@ export function emitFiles(resolver: EmitResolver, host: EmitHost, targetSourceFi
848848
constfilesForEmit=forceDtsEmit ?sourceFiles :filter(sourceFiles,isSourceFileNotJson);
849849
// Setup and perform the transformation to retrieve declarations from the input files
850850
constinputListOrBundle=compilerOptions.outFile ?[factory.createBundle(filesForEmit)] :filesForEmit;
851-
if(emitOnly&&!getEmitDeclarations(compilerOptions)){
852-
// Checker wont collect the linked aliases since thats only done when declaration is enabled.
851+
if((emitOnly&&!getEmitDeclarations(compilerOptions))||compilerOptions.noCheck){
852+
// Checker wont collect the linked aliases since thats only done when declaration is enabled and checking is performed.
853853
// Do that here when emitting only dts files
854854
filesForEmit.forEach(collectLinkedAliases);
855855
}

‎src/compiler/program.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4425,6 +4425,15 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
44254425
}
44264426
}
44274427

4428+
if(options.noCheck){
4429+
if(options.noEmit){
4430+
createDiagnosticForOptionName(Diagnostics.Option_0_cannot_be_specified_with_option_1,"noCheck","noEmit");
4431+
}
4432+
if(!options.emitDeclarationOnly){
4433+
createDiagnosticForOptionName(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1,"noCheck","emitDeclarationOnly");
4434+
}
4435+
}
4436+
44284437
if(
44294438
options.emitDecoratorMetadata&&
44304439
!options.experimentalDecorators

‎src/compiler/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7270,6 +7270,7 @@ export interface CompilerOptions {
72707270
moduleDetection?:ModuleDetectionKind;
72717271
newLine?:NewLineKind;
72727272
noEmit?:boolean;
7273+
/**@internal */noCheck?:boolean;
72737274
/**@internal */noEmitForJsFiles?:boolean;
72747275
noEmitHelpers?:boolean;
72757276
noEmitOnError?:boolean;

‎src/compiler/utilities.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9967,6 +9967,7 @@ export function skipTypeChecking(sourceFile: SourceFile, options: CompilerOption
99679967
// '/// <reference no-default-lib="true"/>' directive.
99689968
return(options.skipLibCheck&&sourceFile.isDeclarationFile||
99699969
options.skipDefaultLibCheck&&sourceFile.hasNoDefaultLib)||
9970+
options.noCheck||
99709971
host.isSourceOfProjectReferenceRedirect(sourceFile.fileName);
99719972
}
99729973

‎src/harness/harnessIO.ts

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ export namespace Compiler {
303303
{name:"noTypesAndSymbols",type:"boolean",defaultValueDescription:false},
304304
// Emitted js baseline will print full paths for every output file
305305
{name:"fullEmitPaths",type:"boolean",defaultValueDescription:false},
306+
{name:"noCheck",type:"boolean",defaultValueDescription:false},
306307
{name:"reportDiagnostics",type:"boolean",defaultValueDescription:false},// used to enable error collection in `transpile` baselines
307308
];
308309

@@ -371,6 +372,8 @@ export namespace Compiler {
371372
fileOptions?:any;
372373
}
373374

375+
exporttypeCompileFilesResult=compiler.CompilationResult&{repeat(newOptions:TestCaseParser.CompilerSettings):CompileFilesResult;};
376+
374377
exportfunctioncompileFiles(
375378
inputFiles:TestFile[],
376379
otherFiles:TestFile[],
@@ -379,7 +382,8 @@ export namespace Compiler {
379382
// Current directory is needed for rwcRunner to be able to use currentDirectory defined in json file
380383
currentDirectory:string|undefined,
381384
symlinks?:vfs.FileSet,
382-
):compiler.CompilationResult{
385+
):CompileFilesResult{
386+
constoriginalCurrentDirectory=currentDirectory;
383387
constoptions:ts.CompilerOptions&HarnessOptions=compilerOptions ?ts.cloneCompilerOptions(compilerOptions) :{noResolve:false};
384388
options.newLine=options.newLine||ts.NewLineKind.CarriageReturnLineFeed;
385389
options.noErrorTruncation=true;
@@ -428,7 +432,8 @@ export namespace Compiler {
428432
consthost=newfakes.CompilerHost(fs,options);
429433
constresult=compiler.compileFiles(host,programFileNames,options,typeScriptVersion);
430434
result.symlinks=symlinks;
431-
returnresult;
435+
(resultasCompileFilesResult).repeat=newOptions=>compileFiles(inputFiles,otherFiles,{ ...harnessSettings, ...newOptions},compilerOptions,originalCurrentDirectory,symlinks);
436+
returnresultasCompileFilesResult;
432437
}
433438

434439
exportinterfaceDeclarationCompilationContext{
@@ -944,7 +949,7 @@ export namespace Compiler {
944949
return"\n//// https://sokra.github.io/source-map-visualization"+hash+"\n";
945950
}
946951

947-
exportfunctiondoJsEmitBaseline(baselinePath:string,header:string,options:ts.CompilerOptions,result:compiler.CompilationResult,tsConfigFiles:readonlyTestFile[],toBeCompiled:readonlyTestFile[],otherFiles:readonlyTestFile[],harnessSettings:TestCaseParser.CompilerSettings){
952+
exportfunctiondoJsEmitBaseline(baselinePath:string,header:string,options:ts.CompilerOptions,result:CompileFilesResult,tsConfigFiles:readonlyTestFile[],toBeCompiled:readonlyTestFile[],otherFiles:readonlyTestFile[],harnessSettings:TestCaseParser.CompilerSettings){
948953
if(!options.noEmit&&!options.emitDeclarationOnly&&result.js.size===0&&result.diagnostics.length===0){
949954
thrownewError("Expected at least one js file to be emitted or at least one error to be created.");
950955
}
@@ -996,9 +1001,33 @@ export namespace Compiler {
9961001
jsCode+="\r\n\r\n";
9971002
jsCode+=getErrorBaseline(tsConfigFiles.concat(declFileCompilationResult.declInputFiles,declFileCompilationResult.declOtherFiles),declFileCompilationResult.declResult.diagnostics);
9981003
}
1004+
elseif(!options.noCheck&&!options.noEmit&&(options.composite||options.declaration||options.emitDeclarationOnly)){
1005+
constwithoutChecking=result.repeat({noCheck:"true",emitDeclarationOnly:"true"});
1006+
compareResultFileSets(withoutChecking.dts,result.dts);
1007+
}
9991008

10001009
// eslint-disable-next-line no-restricted-syntax
10011010
Baseline.runBaseline(baselinePath.replace(/\.tsx?/,ts.Extension.Js),jsCode.length>0 ?tsCode+"\r\n\r\n"+jsCode :null);
1011+
1012+
functioncompareResultFileSets(a:ReadonlyMap<string,documents.TextDocument>,b:ReadonlyMap<string,documents.TextDocument>){
1013+
a.forEach((doc,key)=>{
1014+
constoriginal=b.get(key);
1015+
if(!original){
1016+
jsCode+=`\r\n\r\n!!!! File${Utils.removeTestPathPrefixes(doc.file)} missing from original emit, but present in noCheck emit\r\n`;
1017+
jsCode+=fileOutput(doc,harnessSettings);
1018+
}
1019+
elseif(original.text!==doc.text){
1020+
jsCode+=`\r\n\r\n!!!! File${Utils.removeTestPathPrefixes(doc.file)} differs from original emit in noCheck emit\r\n`;
1021+
constDiff=require("diff");
1022+
constexpected=original.text;
1023+
constactual=doc.text;
1024+
constpatch=Diff.createTwoFilesPatch("Expected","Actual",expected,actual,"The full check baseline","with noCheck set");
1025+
constfileName=harnessSettings.fullEmitPaths ?Utils.removeTestPathPrefixes(doc.file) :ts.getBaseFileName(doc.file);
1026+
jsCode+="//// ["+fileName+"]\r\n";
1027+
jsCode+=patch;
1028+
}
1029+
});
1030+
}
10021031
}
10031032

10041033
functionfileOutput(file:documents.TextDocument,harnessSettings:TestCaseParser.CompilerSettings):string{

‎src/services/transpile.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ export function transpileModule(input: string, transpileOptions: TranspileOption
7575
* - noResolve = true
7676
* - declaration = true
7777
* - emitDeclarationOnly = true
78+
* - noCheck = true
7879
* Note that this declaration file may differ from one produced by a full program typecheck,
7980
* in that only types in the single input file are available to be used in the generated declarations.
8081
*/
@@ -141,6 +142,7 @@ function transpileWorker(input: string, transpileOptions: TranspileOptions, decl
141142
options.declaration=true;
142143
options.emitDeclarationOnly=true;
143144
options.isolatedDeclarations=true;
145+
options.noCheck=true;
144146
}
145147
else{
146148
options.declaration=false;

‎src/testRunner/compilerRunner.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import*ascompilerfrom"./_namespaces/compiler";
21
import{
32
Baseline,
43
Compiler,
@@ -171,7 +170,7 @@ class CompilerTest {
171170
privateconfiguredName:string;
172171
privateharnessSettings:TestCaseParser.CompilerSettings;
173172
privatehasNonDtsFiles:boolean;
174-
privateresult:compiler.CompilationResult;
173+
privateresult:Compiler.CompileFilesResult;
175174
privateoptions:ts.CompilerOptions;
176175
privatetsConfigFiles:Compiler.TestFile[];
177176
// equivalent to the files that will be passed on the command line

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp