From e1267d28020ca55f34a9b317f5d8f8e60c360780 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Mon, 16 Jun 2025 13:36:42 -0700 Subject: [PATCH 1/4] Remove ScriptTarget from source affecting options --- internal/api/encoder/encoder_test.go | 4 +- internal/ast/ast.go | 3 -- internal/astnav/tokens_test.go | 4 +- internal/binder/binder.go | 16 +------ internal/compiler/program.go | 1 - internal/core/compileroptions.go | 2 - internal/execute/tsc.go | 4 +- internal/format/api_test.go | 4 +- internal/parser/parser.go | 9 +--- internal/parser/parser_test.go | 2 - internal/printer/printer.go | 9 ++-- internal/scanner/scanner.go | 8 +--- .../testutil/parsetestutil/parsetestutil.go | 4 +- ...unctionDeclarationInStrictClass.errors.txt | 5 +-- ...onDeclarationInStrictClass.errors.txt.diff | 18 ++++++++ ...nctionDeclarationInStrictModule.errors.txt | 5 +-- ...pedFunctionDeclarationStrictES5.errors.txt | 5 +-- ...nctionDeclarationStrictES5.errors.txt.diff | 17 ++++++++ ...ameFunctionDeclarationStrictES5.errors.txt | 8 +--- ...nctionDeclarationStrictES5.errors.txt.diff | 31 +++++++++++++ .../compiler/downlevelLetConst18.errors.txt | 39 ----------------- .../downlevelLetConst18.errors.txt.diff | 43 +++++++++++++++++++ .../compiler/downlevelLetConst19.errors.txt | 25 ----------- .../downlevelLetConst19.errors.txt.diff | 29 +++++++++++++ ...ntDeclarationListInLoopNoCrash1.errors.txt | 5 ++- ...larationListInLoopNoCrash1.errors.txt.diff | 17 ++++++++ ...ntDeclarationListInLoopNoCrash2.errors.txt | 12 ++++++ ...larationListInLoopNoCrash2.errors.txt.diff | 16 +++++++ ...ntDeclarationListInLoopNoCrash3.errors.txt | 5 ++- ...larationListInLoopNoCrash3.errors.txt.diff | 28 ++++++++++++ ...ntDeclarationListInLoopNoCrash4.errors.txt | 5 ++- ...larationListInLoopNoCrash4.errors.txt.diff | 26 +++++++++++ ...rationNoCrash1(module=commonjs).errors.txt | 5 ++- ...nNoCrash1(module=commonjs).errors.txt.diff | 22 ++++++++++ ...larationNoCrash1(module=esnext).errors.txt | 5 ++- ...ionNoCrash1(module=esnext).errors.txt.diff | 22 ++++++++++ ...larationNoCrash1(module=system).errors.txt | 5 ++- ...nDeclarationInStrictModule.errors.txt.diff | 16 +++++++ ...ionNoCrash1(module=system).errors.txt.diff | 22 ++++++++++ 39 files changed, 360 insertions(+), 146 deletions(-) create mode 100644 testdata/baselines/reference/submodule/compiler/blockScopedFunctionDeclarationInStrictClass.errors.txt.diff create mode 100644 testdata/baselines/reference/submodule/compiler/blockScopedFunctionDeclarationStrictES5.errors.txt.diff create mode 100644 testdata/baselines/reference/submodule/compiler/blockScopedSameNameFunctionDeclarationStrictES5.errors.txt.diff delete mode 100644 testdata/baselines/reference/submodule/compiler/downlevelLetConst18.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/downlevelLetConst18.errors.txt.diff delete mode 100644 testdata/baselines/reference/submodule/compiler/downlevelLetConst19.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/downlevelLetConst19.errors.txt.diff create mode 100644 testdata/baselines/reference/submodule/conformance/labeledStatementDeclarationListInLoopNoCrash1.errors.txt.diff create mode 100644 testdata/baselines/reference/submodule/conformance/labeledStatementDeclarationListInLoopNoCrash2.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/labeledStatementDeclarationListInLoopNoCrash2.errors.txt.diff create mode 100644 testdata/baselines/reference/submodule/conformance/labeledStatementDeclarationListInLoopNoCrash3.errors.txt.diff create mode 100644 testdata/baselines/reference/submodule/conformance/labeledStatementDeclarationListInLoopNoCrash4.errors.txt.diff create mode 100644 testdata/baselines/reference/submodule/conformance/labeledStatementExportDeclarationNoCrash1(module=commonjs).errors.txt.diff create mode 100644 testdata/baselines/reference/submodule/conformance/labeledStatementExportDeclarationNoCrash1(module=esnext).errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/blockScopedFunctionDeclarationInStrictModule.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/labeledStatementExportDeclarationNoCrash1(module=system).errors.txt.diff diff --git a/internal/api/encoder/encoder_test.go b/internal/api/encoder/encoder_test.go index d72fafe5ae..682f29f0e1 100644 --- a/internal/api/encoder/encoder_test.go +++ b/internal/api/encoder/encoder_test.go @@ -18,9 +18,7 @@ import ( "gotest.tools/v3/assert" ) -var parseCompilerOptions = &core.SourceFileAffectingCompilerOptions{ - EmitScriptTarget: core.ScriptTargetLatest, -} +var parseCompilerOptions = &core.SourceFileAffectingCompilerOptions{} func TestEncodeSourceFile(t *testing.T) { t.Parallel() diff --git a/internal/ast/ast.go b/internal/ast/ast.go index ddd62ebed4..4436506d17 100644 --- a/internal/ast/ast.go +++ b/internal/ast/ast.go @@ -9995,7 +9995,6 @@ type SourceFile struct { diagnostics []*Diagnostic jsdocDiagnostics []*Diagnostic - LanguageVersion core.ScriptTarget LanguageVariant core.LanguageVariant ScriptKind core.ScriptKind IsDeclarationFile bool @@ -10050,7 +10049,6 @@ func (f *NodeFactory) NewSourceFile(text string, fileName string, path tspath.Pa data.fileName = fileName data.path = path data.Statements = statements - data.LanguageVersion = core.ScriptTargetLatest return f.newNode(KindSourceFile, data) } @@ -10120,7 +10118,6 @@ func (node *SourceFile) IsJS() bool { func (node *SourceFile) copyFrom(other *SourceFile) { // Do not copy fields set by NewSourceFile (Text, FileName, Path, or Statements) - node.LanguageVersion = other.LanguageVersion node.LanguageVariant = other.LanguageVariant node.ScriptKind = other.ScriptKind node.IsDeclarationFile = other.IsDeclarationFile diff --git a/internal/astnav/tokens_test.go b/internal/astnav/tokens_test.go index 208b137d60..e12e246a7b 100644 --- a/internal/astnav/tokens_test.go +++ b/internal/astnav/tokens_test.go @@ -26,9 +26,7 @@ var testFiles = []string{ filepath.Join(repo.TypeScriptSubmodulePath, "src/services/mapCode.ts"), } -var parseCompilerOptions = &core.SourceFileAffectingCompilerOptions{ - EmitScriptTarget: core.ScriptTargetLatest, -} +var parseCompilerOptions = &core.SourceFileAffectingCompilerOptions{} func TestGetTokenAtPosition(t *testing.T) { t.Parallel() diff --git a/internal/binder/binder.go b/internal/binder/binder.go index 393d4a8efb..684f966784 100644 --- a/internal/binder/binder.go +++ b/internal/binder/binder.go @@ -43,7 +43,6 @@ const ( type Binder struct { file *ast.SourceFile options *core.SourceFileAffectingCompilerOptions - languageVersion core.ScriptTarget bindFunc func(*ast.Node) bool unreachableFlow *ast.FlowNode reportedUnreachableFlow *ast.FlowNode @@ -119,7 +118,6 @@ func bindSourceFile(file *ast.SourceFile, options *core.SourceFileAffectingCompi defer putBinder(b) b.file = file b.options = options - b.languageVersion = options.EmitScriptTarget b.inStrictMode = options.BindInStrictMode && !file.IsDeclarationFile || ast.IsExternalModule(file) b.unreachableFlow = b.newFlowNode(ast.FlowFlagsUnreachable) b.reportedUnreachableFlow = b.newFlowNode(ast.FlowFlagsUnreachable) @@ -1179,7 +1177,6 @@ func (b *Binder) bindParameter(node *ast.Node) { func (b *Binder) bindFunctionDeclaration(node *ast.Node) { b.checkStrictModeFunctionName(node) if b.inStrictMode { - b.checkStrictModeFunctionDeclaration(node) b.bindBlockScopedDeclaration(node, ast.SymbolFlagsFunction, ast.SymbolFlagsFunctionExcludes) } else { b.declareSymbolAndAddToSymbolTable(node, ast.SymbolFlagsFunction, ast.SymbolFlagsFunctionExcludes) @@ -1362,17 +1359,6 @@ func (b *Binder) checkStrictModeFunctionName(node *ast.Node) { } } -func (b *Binder) checkStrictModeFunctionDeclaration(node *ast.Node) { - if b.languageVersion < core.ScriptTargetES2015 { - // Report error if function is not top level function declaration - if b.blockScopeContainer.Kind != ast.KindSourceFile && b.blockScopeContainer.Kind != ast.KindModuleDeclaration && !ast.IsFunctionLikeOrClassStaticBlockDeclaration(b.blockScopeContainer) { - // We check first if the name is inside class declaration or class expression; if so give explicit message - // otherwise report generic error message. - b.errorOnNode(node, b.getStrictModeBlockScopeFunctionDeclarationMessage(node)) - } - } -} - func (b *Binder) getStrictModeBlockScopeFunctionDeclarationMessage(node *ast.Node) *diagnostics.Message { // Provide specialized messages to help the user understand why we think they're in strict mode. if ast.GetContainingClass(node) != nil { @@ -1441,7 +1427,7 @@ func (b *Binder) checkStrictModeWithStatement(node *ast.Node) { func (b *Binder) checkStrictModeLabeledStatement(node *ast.Node) { // Grammar checking for labeledStatement - if b.inStrictMode && b.options.EmitScriptTarget >= core.ScriptTargetES2015 { + if b.inStrictMode { data := node.AsLabeledStatement() if ast.IsDeclarationStatement(data.Statement) || ast.IsVariableStatement(data.Statement) { b.errorOnFirstToken(data.Label, diagnostics.A_label_is_not_allowed_here) diff --git a/internal/compiler/program.go b/internal/compiler/program.go index 3be053f2d7..47f39ed00a 100644 --- a/internal/compiler/program.go +++ b/internal/compiler/program.go @@ -261,7 +261,6 @@ func canReplaceFileInProgram(file1 *ast.SourceFile, file2 *ast.SourceFile) bool return file2 != nil && file1.FileName() == file2.FileName() && file1.Path() == file2.Path() && - file1.LanguageVersion == file2.LanguageVersion && file1.LanguageVariant == file2.LanguageVariant && file1.ScriptKind == file2.ScriptKind && file1.IsDeclarationFile == file2.IsDeclarationFile && diff --git a/internal/core/compileroptions.go b/internal/core/compileroptions.go index e6c7f859e9..d8cf384808 100644 --- a/internal/core/compileroptions.go +++ b/internal/core/compileroptions.go @@ -357,7 +357,6 @@ type SourceFileAffectingCompilerOptions struct { BindInStrictMode bool EmitModuleDetectionKind ModuleDetectionKind EmitModuleKind ModuleKind - EmitScriptTarget ScriptTarget JsxEmit JsxEmit NoFallthroughCasesInSwitch Tristate ShouldPreserveConstEnums bool @@ -371,7 +370,6 @@ func (options *CompilerOptions) SourceFileAffecting() *SourceFileAffectingCompil BindInStrictMode: options.AlwaysStrict.IsTrue() || options.Strict.IsTrue(), EmitModuleDetectionKind: options.GetEmitModuleDetectionKind(), EmitModuleKind: options.GetEmitModuleKind(), - EmitScriptTarget: options.GetEmitScriptTarget(), JsxEmit: options.Jsx, NoFallthroughCasesInSwitch: options.NoFallthroughCasesInSwitch, ShouldPreserveConstEnums: options.ShouldPreserveConstEnums(), diff --git a/internal/execute/tsc.go b/internal/execute/tsc.go index a252f6e584..64092e46b2 100644 --- a/internal/execute/tsc.go +++ b/internal/execute/tsc.go @@ -78,9 +78,7 @@ func fmtMain(sys System, input, output string) ExitStatus { string(pathified), pathified, text, - &core.SourceFileAffectingCompilerOptions{ - EmitScriptTarget: core.ScriptTargetLatest, - }, + &core.SourceFileAffectingCompilerOptions{}, nil, scanner.JSDocParsingModeParseAll, ) diff --git a/internal/format/api_test.go b/internal/format/api_test.go index d60227f7dd..39b3a83ce8 100644 --- a/internal/format/api_test.go +++ b/internal/format/api_test.go @@ -34,9 +34,7 @@ func applyBulkEdits(text string, edits []core.TextChange) string { return b.String() } -var parseCompilerOptions = &core.SourceFileAffectingCompilerOptions{ - EmitScriptTarget: core.ScriptTargetLatest, -} +var parseCompilerOptions = &core.SourceFileAffectingCompilerOptions{} func TestFormat(t *testing.T) { t.Parallel() diff --git a/internal/parser/parser.go b/internal/parser/parser.go index de189f3d19..cb29ba791e 100644 --- a/internal/parser/parser.go +++ b/internal/parser/parser.go @@ -55,7 +55,6 @@ type Parser struct { sourceText string options *core.SourceFileAffectingCompilerOptions metadata *ast.SourceFileMetaData - languageVersion core.ScriptTarget scriptKind core.ScriptKind languageVariant core.LanguageVariant diagnostics []*ast.Diagnostic @@ -110,7 +109,7 @@ func ParseSourceFile(fileName string, path tspath.Path, sourceText string, optio func ParseJSONText(fileName string, path tspath.Path, sourceText string) *ast.SourceFile { p := getParser() defer putParser(p) - p.initializeState(fileName, path, sourceText, &core.SourceFileAffectingCompilerOptions{EmitScriptTarget: core.ScriptTargetES2015}, nil, core.ScriptKindJSON, scanner.JSDocParsingModeParseAll) + p.initializeState(fileName, path, sourceText, &core.SourceFileAffectingCompilerOptions{}, nil, core.ScriptKindJSON, scanner.JSDocParsingModeParseAll) p.nextToken() pos := p.nodePos() var statements *ast.NodeList @@ -176,7 +175,6 @@ func ParseJSONText(fileName string, path tspath.Path, sourceText string) *ast.So p.finishNode(node, pos) result := node.AsSourceFile() result.ScriptKind = core.ScriptKindJSON - result.LanguageVersion = core.ScriptTargetES2015 result.Flags |= p.sourceFlags result.SetDiagnostics(attachFileToDiagnostics(p.diagnostics, result)) result.SetJSDocDiagnostics(attachFileToDiagnostics(p.jsdocDiagnostics, result)) @@ -186,7 +184,7 @@ func ParseJSONText(fileName string, path tspath.Path, sourceText string) *ast.So func ParseIsolatedEntityName(text string, languageVersion core.ScriptTarget) *ast.EntityName { p := getParser() defer putParser(p) - p.initializeState("", "", text, &core.SourceFileAffectingCompilerOptions{EmitScriptTarget: languageVersion}, nil, core.ScriptKindJS, scanner.JSDocParsingModeParseAll) + p.initializeState("", "", text, &core.SourceFileAffectingCompilerOptions{}, nil, core.ScriptKindJS, scanner.JSDocParsingModeParseAll) p.nextToken() entityName := p.parseEntityName(true, nil) return core.IfElse(p.token == ast.KindEndOfFile && len(p.diagnostics) == 0, entityName, nil) @@ -203,7 +201,6 @@ func (p *Parser) initializeState(fileName string, path tspath.Path, sourceText s p.sourceText = sourceText p.options = options p.metadata = metadata - p.languageVersion = options.EmitScriptTarget p.scriptKind = ensureScriptKind(fileName, scriptKind) p.languageVariant = ast.GetLanguageVariant(p.scriptKind) switch p.scriptKind { @@ -216,7 +213,6 @@ func (p *Parser) initializeState(fileName string, path tspath.Path, sourceText s } p.scanner.SetText(p.sourceText) p.scanner.SetOnError(p.scanError) - p.scanner.SetScriptTarget(p.languageVersion) p.scanner.SetLanguageVariant(p.languageVariant) p.scanner.SetScriptKind(p.scriptKind) p.scanner.SetJSDocParsingMode(jsdocParsingMode) @@ -350,7 +346,6 @@ func (p *Parser) finishSourceFile(result *ast.SourceFile, isDeclarationFile bool result.SetDiagnostics(attachFileToDiagnostics(p.diagnostics, result)) result.CommonJSModuleIndicator = p.commonJSModuleIndicator result.IsDeclarationFile = isDeclarationFile - result.LanguageVersion = p.languageVersion result.LanguageVariant = p.languageVariant result.ScriptKind = p.scriptKind result.Flags |= p.sourceFlags diff --git a/internal/parser/parser_test.go b/internal/parser/parser_test.go index 0833bd4b14..4231f13522 100644 --- a/internal/parser/parser_test.go +++ b/internal/parser/parser_test.go @@ -34,7 +34,6 @@ func BenchmarkParse(b *testing.B) { path := tspath.ToPath(fileName, "/", osvfs.FS().UseCaseSensitiveFileNames()) sourceText := f.ReadFile(b) options := &core.SourceFileAffectingCompilerOptions{ - EmitScriptTarget: core.ScriptTargetESNext, } for _, jsdoc := range jsdocModes { @@ -135,7 +134,6 @@ func FuzzParser(f *testing.F) { } options := &core.SourceFileAffectingCompilerOptions{ - EmitScriptTarget: scriptTarget, } ParseSourceFile(fileName, path, sourceText, options, nil, jsdocParsingMode) diff --git a/internal/printer/printer.go b/internal/printer/printer.go index 21e36e3ef3..8d68f20015 100644 --- a/internal/printer/printer.go +++ b/internal/printer/printer.go @@ -844,10 +844,9 @@ func (p *Printer) shouldAllowTrailingComma(node *ast.Node, list *ast.NodeList) b return false } - target := p.currentSourceFile.LanguageVersion switch node.Kind { case ast.KindObjectLiteralExpression: - return target >= core.ScriptTargetES5 + return true case ast.KindArrayLiteralExpression, ast.KindArrowFunction, ast.KindConstructor, @@ -874,11 +873,11 @@ func (p *Printer) shouldAllowTrailingComma(node *ast.Node, list *ast.NodeList) b case ast.KindFunctionDeclaration, ast.KindFunctionExpression, ast.KindMethodDeclaration: - return target >= core.ScriptTargetES2015 || list == node.FunctionLikeData().TypeParameters + return true case ast.KindCallExpression: - return target >= core.ScriptTargetES2015 || list == node.AsCallExpression().TypeArguments + return true case ast.KindNewExpression: - return target >= core.ScriptTargetES2015 || list == node.AsNewExpression().TypeArguments + return true } return false diff --git a/internal/scanner/scanner.go b/internal/scanner/scanner.go index 69df81e277..1071b9da3a 100644 --- a/internal/scanner/scanner.go +++ b/internal/scanner/scanner.go @@ -218,7 +218,6 @@ type ScannerState struct { type Scanner struct { text string // TODO: remove this? unused except for (unimplemented) regex checking - languageVersion core.ScriptTarget languageVariant core.LanguageVariant onError ErrorCallback skipTrivia bool @@ -231,7 +230,7 @@ func defaultScanner() Scanner { // Using a function rather than a global is intentional; this function is // inlined as pure code (zeroing + moves), whereas a global requires write // barriers since the memory is mutable. - return Scanner{languageVersion: core.ScriptTargetLatest, skipTrivia: true} + return Scanner{skipTrivia: true} } func NewScanner() *Scanner { @@ -348,10 +347,6 @@ func (s *Scanner) SetOnError(errorCallback ErrorCallback) { s.onError = errorCallback } -func (s *Scanner) SetScriptTarget(scriptTarget core.ScriptTarget) { - s.languageVersion = scriptTarget -} - func (s *Scanner) SetScriptKind(scriptKind core.ScriptKind) { s.scriptKind = scriptKind } @@ -2246,7 +2241,6 @@ func GetScannerForSourceFile(sourceFile *ast.SourceFile, pos int) *Scanner { s := NewScanner() s.text = sourceFile.Text() s.pos = pos - s.languageVersion = sourceFile.LanguageVersion s.languageVariant = sourceFile.LanguageVariant s.Scan() return s diff --git a/internal/testutil/parsetestutil/parsetestutil.go b/internal/testutil/parsetestutil/parsetestutil.go index 76833960d0..e006e89b9f 100644 --- a/internal/testutil/parsetestutil/parsetestutil.go +++ b/internal/testutil/parsetestutil/parsetestutil.go @@ -12,9 +12,7 @@ import ( "github.com/microsoft/typescript-go/internal/tspath" ) -var parseCompilerOptions = &core.SourceFileAffectingCompilerOptions{ - EmitScriptTarget: core.ScriptTargetLatest, -} +var parseCompilerOptions = &core.SourceFileAffectingCompilerOptions{} // Simplifies parsing an input string into a SourceFile for testing purposes. func ParseTypeScript(text string, jsx bool) *ast.SourceFile { diff --git a/testdata/baselines/reference/submodule/compiler/blockScopedFunctionDeclarationInStrictClass.errors.txt b/testdata/baselines/reference/submodule/compiler/blockScopedFunctionDeclarationInStrictClass.errors.txt index f0e4c2cc06..0fcc185589 100644 --- a/testdata/baselines/reference/submodule/compiler/blockScopedFunctionDeclarationInStrictClass.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/blockScopedFunctionDeclarationInStrictClass.errors.txt @@ -1,14 +1,11 @@ -blockScopedFunctionDeclarationInStrictClass.ts(4,22): error TS1251: Function declarations are not allowed inside blocks in strict mode when targeting 'ES5'. Class definitions are automatically in strict mode. blockScopedFunctionDeclarationInStrictClass.ts(7,9): error TS2304: Cannot find name 'foo'. -==== blockScopedFunctionDeclarationInStrictClass.ts (2 errors) ==== +==== blockScopedFunctionDeclarationInStrictClass.ts (1 errors) ==== class c { method() { if (true) { function foo() { } - ~~~ -!!! error TS1251: Function declarations are not allowed inside blocks in strict mode when targeting 'ES5'. Class definitions are automatically in strict mode. foo(); // ok } foo(); // not ok diff --git a/testdata/baselines/reference/submodule/compiler/blockScopedFunctionDeclarationInStrictClass.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/blockScopedFunctionDeclarationInStrictClass.errors.txt.diff new file mode 100644 index 0000000000..a92cdeb5e1 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/blockScopedFunctionDeclarationInStrictClass.errors.txt.diff @@ -0,0 +1,18 @@ +--- old.blockScopedFunctionDeclarationInStrictClass.errors.txt ++++ new.blockScopedFunctionDeclarationInStrictClass.errors.txt +@@= skipped -0, +0 lines =@@ +-blockScopedFunctionDeclarationInStrictClass.ts(4,22): error TS1251: Function declarations are not allowed inside blocks in strict mode when targeting 'ES5'. Class definitions are automatically in strict mode. + blockScopedFunctionDeclarationInStrictClass.ts(7,9): error TS2304: Cannot find name 'foo'. + + +-==== blockScopedFunctionDeclarationInStrictClass.ts (2 errors) ==== ++==== blockScopedFunctionDeclarationInStrictClass.ts (1 errors) ==== + class c { + method() { + if (true) { + function foo() { } +- ~~~ +-!!! error TS1251: Function declarations are not allowed inside blocks in strict mode when targeting 'ES5'. Class definitions are automatically in strict mode. + foo(); // ok + } + foo(); // not ok \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/blockScopedFunctionDeclarationInStrictModule.errors.txt b/testdata/baselines/reference/submodule/compiler/blockScopedFunctionDeclarationInStrictModule.errors.txt index 175fd5671a..f958ba0e05 100644 --- a/testdata/baselines/reference/submodule/compiler/blockScopedFunctionDeclarationInStrictModule.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/blockScopedFunctionDeclarationInStrictModule.errors.txt @@ -1,12 +1,9 @@ -blockScopedFunctionDeclarationInStrictModule.ts(2,14): error TS1252: Function declarations are not allowed inside blocks in strict mode when targeting 'ES5'. Modules are automatically in strict mode. blockScopedFunctionDeclarationInStrictModule.ts(6,10): error TS2304: Cannot find name 'foo'. -==== blockScopedFunctionDeclarationInStrictModule.ts (2 errors) ==== +==== blockScopedFunctionDeclarationInStrictModule.ts (1 errors) ==== if (true) { function foo() { } - ~~~ -!!! error TS1252: Function declarations are not allowed inside blocks in strict mode when targeting 'ES5'. Modules are automatically in strict mode. foo(); // ok } diff --git a/testdata/baselines/reference/submodule/compiler/blockScopedFunctionDeclarationStrictES5.errors.txt b/testdata/baselines/reference/submodule/compiler/blockScopedFunctionDeclarationStrictES5.errors.txt index 857941c464..120e1f45d5 100644 --- a/testdata/baselines/reference/submodule/compiler/blockScopedFunctionDeclarationStrictES5.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/blockScopedFunctionDeclarationStrictES5.errors.txt @@ -1,13 +1,10 @@ -blockScopedFunctionDeclarationStrictES5.ts(3,14): error TS1250: Function declarations are not allowed inside blocks in strict mode when targeting 'ES5'. blockScopedFunctionDeclarationStrictES5.ts(6,1): error TS2304: Cannot find name 'foo'. -==== blockScopedFunctionDeclarationStrictES5.ts (2 errors) ==== +==== blockScopedFunctionDeclarationStrictES5.ts (1 errors) ==== "use strict"; if (true) { function foo() { } // Error to declare function in block scope - ~~~ -!!! error TS1250: Function declarations are not allowed inside blocks in strict mode when targeting 'ES5'. foo(); // This call should be ok } foo(); // Error to find name foo diff --git a/testdata/baselines/reference/submodule/compiler/blockScopedFunctionDeclarationStrictES5.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/blockScopedFunctionDeclarationStrictES5.errors.txt.diff new file mode 100644 index 0000000000..9c8c1bcd6c --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/blockScopedFunctionDeclarationStrictES5.errors.txt.diff @@ -0,0 +1,17 @@ +--- old.blockScopedFunctionDeclarationStrictES5.errors.txt ++++ new.blockScopedFunctionDeclarationStrictES5.errors.txt +@@= skipped -0, +0 lines =@@ +-blockScopedFunctionDeclarationStrictES5.ts(3,14): error TS1250: Function declarations are not allowed inside blocks in strict mode when targeting 'ES5'. + blockScopedFunctionDeclarationStrictES5.ts(6,1): error TS2304: Cannot find name 'foo'. + + +-==== blockScopedFunctionDeclarationStrictES5.ts (2 errors) ==== ++==== blockScopedFunctionDeclarationStrictES5.ts (1 errors) ==== + "use strict"; + if (true) { + function foo() { } // Error to declare function in block scope +- ~~~ +-!!! error TS1250: Function declarations are not allowed inside blocks in strict mode when targeting 'ES5'. + foo(); // This call should be ok + } + foo(); // Error to find name foo \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/blockScopedSameNameFunctionDeclarationStrictES5.errors.txt b/testdata/baselines/reference/submodule/compiler/blockScopedSameNameFunctionDeclarationStrictES5.errors.txt index 2a0872026d..2d70db4f6c 100644 --- a/testdata/baselines/reference/submodule/compiler/blockScopedSameNameFunctionDeclarationStrictES5.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/blockScopedSameNameFunctionDeclarationStrictES5.errors.txt @@ -1,18 +1,14 @@ -blockScopedSameNameFunctionDeclarationStrictES5.ts(4,18): error TS1250: Function declarations are not allowed inside blocks in strict mode when targeting 'ES5'. blockScopedSameNameFunctionDeclarationStrictES5.ts(6,13): error TS2554: Expected 0 arguments, but got 1. -blockScopedSameNameFunctionDeclarationStrictES5.ts(9,18): error TS1250: Function declarations are not allowed inside blocks in strict mode when targeting 'ES5'. blockScopedSameNameFunctionDeclarationStrictES5.ts(11,13): error TS2554: Expected 0 arguments, but got 1. blockScopedSameNameFunctionDeclarationStrictES5.ts(14,5): error TS2554: Expected 1 arguments, but got 0. blockScopedSameNameFunctionDeclarationStrictES5.ts(17,1): error TS2554: Expected 1 arguments, but got 0. -==== blockScopedSameNameFunctionDeclarationStrictES5.ts (6 errors) ==== +==== blockScopedSameNameFunctionDeclarationStrictES5.ts (4 errors) ==== "use strict"; function foo(a: number) { if (a === 1) { function foo() { } // Error to declare function in block scope - ~~~ -!!! error TS1250: Function declarations are not allowed inside blocks in strict mode when targeting 'ES5'. foo(); foo(10); // not ok ~~ @@ -20,8 +16,6 @@ blockScopedSameNameFunctionDeclarationStrictES5.ts(17,1): error TS2554: Expected } else { function foo() { } // Error to declare function in block scope - ~~~ -!!! error TS1250: Function declarations are not allowed inside blocks in strict mode when targeting 'ES5'. foo(); foo(10); // not ok ~~ diff --git a/testdata/baselines/reference/submodule/compiler/blockScopedSameNameFunctionDeclarationStrictES5.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/blockScopedSameNameFunctionDeclarationStrictES5.errors.txt.diff new file mode 100644 index 0000000000..dcc648a56c --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/blockScopedSameNameFunctionDeclarationStrictES5.errors.txt.diff @@ -0,0 +1,31 @@ +--- old.blockScopedSameNameFunctionDeclarationStrictES5.errors.txt ++++ new.blockScopedSameNameFunctionDeclarationStrictES5.errors.txt +@@= skipped -0, +0 lines =@@ +-blockScopedSameNameFunctionDeclarationStrictES5.ts(4,18): error TS1250: Function declarations are not allowed inside blocks in strict mode when targeting 'ES5'. + blockScopedSameNameFunctionDeclarationStrictES5.ts(6,13): error TS2554: Expected 0 arguments, but got 1. +-blockScopedSameNameFunctionDeclarationStrictES5.ts(9,18): error TS1250: Function declarations are not allowed inside blocks in strict mode when targeting 'ES5'. + blockScopedSameNameFunctionDeclarationStrictES5.ts(11,13): error TS2554: Expected 0 arguments, but got 1. + blockScopedSameNameFunctionDeclarationStrictES5.ts(14,5): error TS2554: Expected 1 arguments, but got 0. + blockScopedSameNameFunctionDeclarationStrictES5.ts(17,1): error TS2554: Expected 1 arguments, but got 0. + + +-==== blockScopedSameNameFunctionDeclarationStrictES5.ts (6 errors) ==== ++==== blockScopedSameNameFunctionDeclarationStrictES5.ts (4 errors) ==== + "use strict"; + function foo(a: number) { + if (a === 1) { + function foo() { } // Error to declare function in block scope +- ~~~ +-!!! error TS1250: Function declarations are not allowed inside blocks in strict mode when targeting 'ES5'. + foo(); + foo(10); // not ok + ~~ +@@= skipped -19, +15 lines =@@ + } + else { + function foo() { } // Error to declare function in block scope +- ~~~ +-!!! error TS1250: Function declarations are not allowed inside blocks in strict mode when targeting 'ES5'. + foo(); + foo(10); // not ok + ~~ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/downlevelLetConst18.errors.txt b/testdata/baselines/reference/submodule/compiler/downlevelLetConst18.errors.txt deleted file mode 100644 index 1b818a010b..0000000000 --- a/testdata/baselines/reference/submodule/compiler/downlevelLetConst18.errors.txt +++ /dev/null @@ -1,39 +0,0 @@ -downlevelLetConst18.ts(4,14): error TS1250: Function declarations are not allowed inside blocks in strict mode when targeting 'ES5'. -downlevelLetConst18.ts(8,14): error TS1250: Function declarations are not allowed inside blocks in strict mode when targeting 'ES5'. - - -==== downlevelLetConst18.ts (2 errors) ==== - 'use strict' - - for (let x; ;) { - function foo() { x }; - ~~~ -!!! error TS1250: Function declarations are not allowed inside blocks in strict mode when targeting 'ES5'. - } - - for (let x; ;) { - function foo1() { x }; - ~~~~ -!!! error TS1250: Function declarations are not allowed inside blocks in strict mode when targeting 'ES5'. - } - - for (let x; ;) { - (() => { x })(); - } - - for (const x = 1; ;) { - (() => { x })(); - } - - for (let x; ;) { - ({ foo() { x }}) - } - - for (let x; ;) { - ({ get foo() { return x } }) - } - - for (let x; ;) { - ({ set foo(v) { x } }) - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/downlevelLetConst18.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/downlevelLetConst18.errors.txt.diff new file mode 100644 index 0000000000..53cd185a95 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/downlevelLetConst18.errors.txt.diff @@ -0,0 +1,43 @@ +--- old.downlevelLetConst18.errors.txt ++++ new.downlevelLetConst18.errors.txt +@@= skipped -0, +0 lines =@@ +-downlevelLetConst18.ts(4,14): error TS1250: Function declarations are not allowed inside blocks in strict mode when targeting 'ES5'. +-downlevelLetConst18.ts(8,14): error TS1250: Function declarations are not allowed inside blocks in strict mode when targeting 'ES5'. +- +- +-==== downlevelLetConst18.ts (2 errors) ==== +- 'use strict' +- +- for (let x; ;) { +- function foo() { x }; +- ~~~ +-!!! error TS1250: Function declarations are not allowed inside blocks in strict mode when targeting 'ES5'. +- } +- +- for (let x; ;) { +- function foo1() { x }; +- ~~~~ +-!!! error TS1250: Function declarations are not allowed inside blocks in strict mode when targeting 'ES5'. +- } +- +- for (let x; ;) { +- (() => { x })(); +- } +- +- for (const x = 1; ;) { +- (() => { x })(); +- } +- +- for (let x; ;) { +- ({ foo() { x }}) +- } +- +- for (let x; ;) { +- ({ get foo() { return x } }) +- } +- +- for (let x; ;) { +- ({ set foo(v) { x } }) +- } +- ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/downlevelLetConst19.errors.txt b/testdata/baselines/reference/submodule/compiler/downlevelLetConst19.errors.txt deleted file mode 100644 index 216ba2d6de..0000000000 --- a/testdata/baselines/reference/submodule/compiler/downlevelLetConst19.errors.txt +++ /dev/null @@ -1,25 +0,0 @@ -downlevelLetConst19.ts(9,14): error TS1250: Function declarations are not allowed inside blocks in strict mode when targeting 'ES5'. - - -==== downlevelLetConst19.ts (1 errors) ==== - 'use strict' - declare function use(a: any); - var x; - function a() { - { - let x; - use(x); - - function b() { - ~ -!!! error TS1250: Function declarations are not allowed inside blocks in strict mode when targeting 'ES5'. - { - let x; - use(x); - } - use(x); - } - } - use(x) - } - use(x) \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/downlevelLetConst19.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/downlevelLetConst19.errors.txt.diff new file mode 100644 index 0000000000..fb3eb9ab2a --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/downlevelLetConst19.errors.txt.diff @@ -0,0 +1,29 @@ +--- old.downlevelLetConst19.errors.txt ++++ new.downlevelLetConst19.errors.txt +@@= skipped -0, +0 lines =@@ +-downlevelLetConst19.ts(9,14): error TS1250: Function declarations are not allowed inside blocks in strict mode when targeting 'ES5'. +- +- +-==== downlevelLetConst19.ts (1 errors) ==== +- 'use strict' +- declare function use(a: any); +- var x; +- function a() { +- { +- let x; +- use(x); +- +- function b() { +- ~ +-!!! error TS1250: Function declarations are not allowed inside blocks in strict mode when targeting 'ES5'. +- { +- let x; +- use(x); +- } +- use(x); +- } +- } +- use(x) +- } +- use(x) ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/labeledStatementDeclarationListInLoopNoCrash1.errors.txt b/testdata/baselines/reference/submodule/conformance/labeledStatementDeclarationListInLoopNoCrash1.errors.txt index 35cdc3ccea..7ea8c06f82 100644 --- a/testdata/baselines/reference/submodule/conformance/labeledStatementDeclarationListInLoopNoCrash1.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/labeledStatementDeclarationListInLoopNoCrash1.errors.txt @@ -1,10 +1,13 @@ +labeledStatementDeclarationListInLoopNoCrash1.ts(3,3): error TS1344: 'A label is not allowed here. labeledStatementDeclarationListInLoopNoCrash1.ts(3,11): error TS1123: Variable declaration list cannot be empty. -==== labeledStatementDeclarationListInLoopNoCrash1.ts (1 errors) ==== +==== labeledStatementDeclarationListInLoopNoCrash1.ts (2 errors) ==== for (let x of []) { var v0 = x; foo: var; + ~~~ +!!! error TS1344: 'A label is not allowed here. !!! error TS1123: Variable declaration list cannot be empty. (function() { return x + v0}); diff --git a/testdata/baselines/reference/submodule/conformance/labeledStatementDeclarationListInLoopNoCrash1.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/labeledStatementDeclarationListInLoopNoCrash1.errors.txt.diff new file mode 100644 index 0000000000..fcf3f5b4bb --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/labeledStatementDeclarationListInLoopNoCrash1.errors.txt.diff @@ -0,0 +1,17 @@ +--- old.labeledStatementDeclarationListInLoopNoCrash1.errors.txt ++++ new.labeledStatementDeclarationListInLoopNoCrash1.errors.txt +@@= skipped -0, +0 lines =@@ ++labeledStatementDeclarationListInLoopNoCrash1.ts(3,3): error TS1344: 'A label is not allowed here. + labeledStatementDeclarationListInLoopNoCrash1.ts(3,11): error TS1123: Variable declaration list cannot be empty. + + +-==== labeledStatementDeclarationListInLoopNoCrash1.ts (1 errors) ==== ++==== labeledStatementDeclarationListInLoopNoCrash1.ts (2 errors) ==== + for (let x of []) { + var v0 = x; + foo: var; ++ ~~~ ++!!! error TS1344: 'A label is not allowed here. + + !!! error TS1123: Variable declaration list cannot be empty. + (function() { return x + v0}); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/labeledStatementDeclarationListInLoopNoCrash2.errors.txt b/testdata/baselines/reference/submodule/conformance/labeledStatementDeclarationListInLoopNoCrash2.errors.txt new file mode 100644 index 0000000000..cccda1a9a3 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/labeledStatementDeclarationListInLoopNoCrash2.errors.txt @@ -0,0 +1,12 @@ +labeledStatementDeclarationListInLoopNoCrash2.ts(3,3): error TS1344: 'A label is not allowed here. + + +==== labeledStatementDeclarationListInLoopNoCrash2.ts (1 errors) ==== + for (let x of []) { + var v0 = x; + foo: var y; + ~~~ +!!! error TS1344: 'A label is not allowed here. + (function() { return x + v0}); + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/labeledStatementDeclarationListInLoopNoCrash2.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/labeledStatementDeclarationListInLoopNoCrash2.errors.txt.diff new file mode 100644 index 0000000000..cb6d70099f --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/labeledStatementDeclarationListInLoopNoCrash2.errors.txt.diff @@ -0,0 +1,16 @@ +--- old.labeledStatementDeclarationListInLoopNoCrash2.errors.txt ++++ new.labeledStatementDeclarationListInLoopNoCrash2.errors.txt +@@= skipped -0, +0 lines =@@ +- ++labeledStatementDeclarationListInLoopNoCrash2.ts(3,3): error TS1344: 'A label is not allowed here. ++ ++ ++==== labeledStatementDeclarationListInLoopNoCrash2.ts (1 errors) ==== ++ for (let x of []) { ++ var v0 = x; ++ foo: var y; ++ ~~~ ++!!! error TS1344: 'A label is not allowed here. ++ (function() { return x + v0}); ++ } ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/labeledStatementDeclarationListInLoopNoCrash3.errors.txt b/testdata/baselines/reference/submodule/conformance/labeledStatementDeclarationListInLoopNoCrash3.errors.txt index 075f135a3b..7580e978e9 100644 --- a/testdata/baselines/reference/submodule/conformance/labeledStatementDeclarationListInLoopNoCrash3.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/labeledStatementDeclarationListInLoopNoCrash3.errors.txt @@ -9,6 +9,7 @@ labeledStatementDeclarationListInLoopNoCrash3.ts(15,42): error TS1005: ')' expec labeledStatementDeclarationListInLoopNoCrash3.ts(15,53): error TS2304: Cannot find name 'fontSize'. labeledStatementDeclarationListInLoopNoCrash3.ts(15,61): error TS1005: ';' expected. labeledStatementDeclarationListInLoopNoCrash3.ts(16,12): error TS1005: ';' expected. +labeledStatementDeclarationListInLoopNoCrash3.ts(16,12): error TS1344: 'A label is not allowed here. labeledStatementDeclarationListInLoopNoCrash3.ts(16,23): error TS1134: Variable declaration expected. labeledStatementDeclarationListInLoopNoCrash3.ts(16,38): error TS2581: Cannot find name '$'. Do you need to install type definitions for jQuery? Try `npm i --save-dev @types/jquery`. labeledStatementDeclarationListInLoopNoCrash3.ts(16,39): error TS1005: ')' expected. @@ -17,7 +18,7 @@ labeledStatementDeclarationListInLoopNoCrash3.ts(16,56): error TS1005: ';' expec labeledStatementDeclarationListInLoopNoCrash3.ts(22,1): error TS1160: Unterminated template literal. -==== labeledStatementDeclarationListInLoopNoCrash3.ts (17 errors) ==== +==== labeledStatementDeclarationListInLoopNoCrash3.ts (18 errors) ==== // https://github.com/microsoft/TypeScript/issues/59345 export class ParseThemeData { @@ -56,6 +57,8 @@ labeledStatementDeclarationListInLoopNoCrash3.ts(22,1): error TS1160: Unterminat `height: var(--button-size-${fontType}-height)`, ~~~~~~ !!! error TS1005: ';' expected. + ~~~~~~ +!!! error TS1344: 'A label is not allowed here. ~ !!! error TS1134: Variable declaration expected. ~ diff --git a/testdata/baselines/reference/submodule/conformance/labeledStatementDeclarationListInLoopNoCrash3.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/labeledStatementDeclarationListInLoopNoCrash3.errors.txt.diff new file mode 100644 index 0000000000..7647917a93 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/labeledStatementDeclarationListInLoopNoCrash3.errors.txt.diff @@ -0,0 +1,28 @@ +--- old.labeledStatementDeclarationListInLoopNoCrash3.errors.txt ++++ new.labeledStatementDeclarationListInLoopNoCrash3.errors.txt +@@= skipped -8, +8 lines =@@ + labeledStatementDeclarationListInLoopNoCrash3.ts(15,53): error TS2304: Cannot find name 'fontSize'. + labeledStatementDeclarationListInLoopNoCrash3.ts(15,61): error TS1005: ';' expected. + labeledStatementDeclarationListInLoopNoCrash3.ts(16,12): error TS1005: ';' expected. ++labeledStatementDeclarationListInLoopNoCrash3.ts(16,12): error TS1344: 'A label is not allowed here. + labeledStatementDeclarationListInLoopNoCrash3.ts(16,23): error TS1134: Variable declaration expected. + labeledStatementDeclarationListInLoopNoCrash3.ts(16,38): error TS2581: Cannot find name '$'. Do you need to install type definitions for jQuery? Try `npm i --save-dev @types/jquery`. + labeledStatementDeclarationListInLoopNoCrash3.ts(16,39): error TS1005: ')' expected. +@@= skipped -8, +9 lines =@@ + labeledStatementDeclarationListInLoopNoCrash3.ts(22,1): error TS1160: Unterminated template literal. + + +-==== labeledStatementDeclarationListInLoopNoCrash3.ts (17 errors) ==== ++==== labeledStatementDeclarationListInLoopNoCrash3.ts (18 errors) ==== + // https://github.com/microsoft/TypeScript/issues/59345 + + export class ParseThemeData { +@@= skipped -39, +39 lines =@@ + `height: var(--button-size-${fontType}-height)`, + ~~~~~~ + !!! error TS1005: ';' expected. ++ ~~~~~~ ++!!! error TS1344: 'A label is not allowed here. + ~ + !!! error TS1134: Variable declaration expected. + ~ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/labeledStatementDeclarationListInLoopNoCrash4.errors.txt b/testdata/baselines/reference/submodule/conformance/labeledStatementDeclarationListInLoopNoCrash4.errors.txt index 8d20a6b2ac..4b7f3b90aa 100644 --- a/testdata/baselines/reference/submodule/conformance/labeledStatementDeclarationListInLoopNoCrash4.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/labeledStatementDeclarationListInLoopNoCrash4.errors.txt @@ -9,12 +9,13 @@ labeledStatementDeclarationListInLoopNoCrash4.ts(13,42): error TS1005: ')' expec labeledStatementDeclarationListInLoopNoCrash4.ts(13,53): error TS2304: Cannot find name 'fontSize'. labeledStatementDeclarationListInLoopNoCrash4.ts(13,61): error TS1005: ';' expected. labeledStatementDeclarationListInLoopNoCrash4.ts(14,12): error TS1005: ';' expected. +labeledStatementDeclarationListInLoopNoCrash4.ts(14,12): error TS1344: 'A label is not allowed here. labeledStatementDeclarationListInLoopNoCrash4.ts(14,27): error TS1005: ',' expected. labeledStatementDeclarationListInLoopNoCrash4.ts(20,1): error TS1005: '}' expected. labeledStatementDeclarationListInLoopNoCrash4.ts(20,1): error TS1160: Unterminated template literal. -==== labeledStatementDeclarationListInLoopNoCrash4.ts (14 errors) ==== +==== labeledStatementDeclarationListInLoopNoCrash4.ts (15 errors) ==== export class ParseThemeData { parseButton(button: any) { const {type, size} = button; @@ -51,6 +52,8 @@ labeledStatementDeclarationListInLoopNoCrash4.ts(20,1): error TS1160: Unterminat `height: var foo`, ~~~~~~ !!! error TS1005: ';' expected. + ~~~~~~ +!!! error TS1344: 'A label is not allowed here. ~~ ].join(';') ~~~~~~~~~~~~~~~~~~~ diff --git a/testdata/baselines/reference/submodule/conformance/labeledStatementDeclarationListInLoopNoCrash4.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/labeledStatementDeclarationListInLoopNoCrash4.errors.txt.diff new file mode 100644 index 0000000000..fccb13ed23 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/labeledStatementDeclarationListInLoopNoCrash4.errors.txt.diff @@ -0,0 +1,26 @@ +--- old.labeledStatementDeclarationListInLoopNoCrash4.errors.txt ++++ new.labeledStatementDeclarationListInLoopNoCrash4.errors.txt +@@= skipped -8, +8 lines =@@ + labeledStatementDeclarationListInLoopNoCrash4.ts(13,53): error TS2304: Cannot find name 'fontSize'. + labeledStatementDeclarationListInLoopNoCrash4.ts(13,61): error TS1005: ';' expected. + labeledStatementDeclarationListInLoopNoCrash4.ts(14,12): error TS1005: ';' expected. ++labeledStatementDeclarationListInLoopNoCrash4.ts(14,12): error TS1344: 'A label is not allowed here. + labeledStatementDeclarationListInLoopNoCrash4.ts(14,27): error TS1005: ',' expected. + labeledStatementDeclarationListInLoopNoCrash4.ts(20,1): error TS1005: '}' expected. + labeledStatementDeclarationListInLoopNoCrash4.ts(20,1): error TS1160: Unterminated template literal. + + +-==== labeledStatementDeclarationListInLoopNoCrash4.ts (14 errors) ==== ++==== labeledStatementDeclarationListInLoopNoCrash4.ts (15 errors) ==== + export class ParseThemeData { + parseButton(button: any) { + const {type, size} = button; +@@= skipped -42, +43 lines =@@ + `height: var foo`, + ~~~~~~ + !!! error TS1005: ';' expected. ++ ~~~~~~ ++!!! error TS1344: 'A label is not allowed here. + ~~ + ].join(';') + ~~~~~~~~~~~~~~~~~~~ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/labeledStatementExportDeclarationNoCrash1(module=commonjs).errors.txt b/testdata/baselines/reference/submodule/conformance/labeledStatementExportDeclarationNoCrash1(module=commonjs).errors.txt index c82821c21e..89400ea7ad 100644 --- a/testdata/baselines/reference/submodule/conformance/labeledStatementExportDeclarationNoCrash1(module=commonjs).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/labeledStatementExportDeclarationNoCrash1(module=commonjs).errors.txt @@ -1,15 +1,18 @@ labeledStatementExportDeclarationNoCrash1.ts(3,14): error TS1155: 'const' declarations must be initialized. +labeledStatementExportDeclarationNoCrash1.ts(4,1): error TS1344: 'A label is not allowed here. labeledStatementExportDeclarationNoCrash1.ts(5,1): error TS1184: Modifiers cannot appear here. labeledStatementExportDeclarationNoCrash1.ts(5,14): error TS1155: 'const' declarations must be initialized. -==== labeledStatementExportDeclarationNoCrash1.ts (3 errors) ==== +==== labeledStatementExportDeclarationNoCrash1.ts (4 errors) ==== // https://github.com/microsoft/TypeScript/issues/59372 export const box: string ~~~ !!! error TS1155: 'const' declarations must be initialized. subTitle: + ~~~~~~~~ +!!! error TS1344: 'A label is not allowed here. export const title: string ~~~~~~ !!! error TS1184: Modifiers cannot appear here. diff --git a/testdata/baselines/reference/submodule/conformance/labeledStatementExportDeclarationNoCrash1(module=commonjs).errors.txt.diff b/testdata/baselines/reference/submodule/conformance/labeledStatementExportDeclarationNoCrash1(module=commonjs).errors.txt.diff new file mode 100644 index 0000000000..a410ffbd35 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/labeledStatementExportDeclarationNoCrash1(module=commonjs).errors.txt.diff @@ -0,0 +1,22 @@ +--- old.labeledStatementExportDeclarationNoCrash1(module=commonjs).errors.txt ++++ new.labeledStatementExportDeclarationNoCrash1(module=commonjs).errors.txt +@@= skipped -0, +0 lines =@@ + labeledStatementExportDeclarationNoCrash1.ts(3,14): error TS1155: 'const' declarations must be initialized. ++labeledStatementExportDeclarationNoCrash1.ts(4,1): error TS1344: 'A label is not allowed here. + labeledStatementExportDeclarationNoCrash1.ts(5,1): error TS1184: Modifiers cannot appear here. + labeledStatementExportDeclarationNoCrash1.ts(5,14): error TS1155: 'const' declarations must be initialized. + + +-==== labeledStatementExportDeclarationNoCrash1.ts (3 errors) ==== ++==== labeledStatementExportDeclarationNoCrash1.ts (4 errors) ==== + // https://github.com/microsoft/TypeScript/issues/59372 + + export const box: string + ~~~ + !!! error TS1155: 'const' declarations must be initialized. + subTitle: ++ ~~~~~~~~ ++!!! error TS1344: 'A label is not allowed here. + export const title: string + ~~~~~~ + !!! error TS1184: Modifiers cannot appear here. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/labeledStatementExportDeclarationNoCrash1(module=esnext).errors.txt b/testdata/baselines/reference/submodule/conformance/labeledStatementExportDeclarationNoCrash1(module=esnext).errors.txt index c82821c21e..89400ea7ad 100644 --- a/testdata/baselines/reference/submodule/conformance/labeledStatementExportDeclarationNoCrash1(module=esnext).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/labeledStatementExportDeclarationNoCrash1(module=esnext).errors.txt @@ -1,15 +1,18 @@ labeledStatementExportDeclarationNoCrash1.ts(3,14): error TS1155: 'const' declarations must be initialized. +labeledStatementExportDeclarationNoCrash1.ts(4,1): error TS1344: 'A label is not allowed here. labeledStatementExportDeclarationNoCrash1.ts(5,1): error TS1184: Modifiers cannot appear here. labeledStatementExportDeclarationNoCrash1.ts(5,14): error TS1155: 'const' declarations must be initialized. -==== labeledStatementExportDeclarationNoCrash1.ts (3 errors) ==== +==== labeledStatementExportDeclarationNoCrash1.ts (4 errors) ==== // https://github.com/microsoft/TypeScript/issues/59372 export const box: string ~~~ !!! error TS1155: 'const' declarations must be initialized. subTitle: + ~~~~~~~~ +!!! error TS1344: 'A label is not allowed here. export const title: string ~~~~~~ !!! error TS1184: Modifiers cannot appear here. diff --git a/testdata/baselines/reference/submodule/conformance/labeledStatementExportDeclarationNoCrash1(module=esnext).errors.txt.diff b/testdata/baselines/reference/submodule/conformance/labeledStatementExportDeclarationNoCrash1(module=esnext).errors.txt.diff new file mode 100644 index 0000000000..1f3407576e --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/labeledStatementExportDeclarationNoCrash1(module=esnext).errors.txt.diff @@ -0,0 +1,22 @@ +--- old.labeledStatementExportDeclarationNoCrash1(module=esnext).errors.txt ++++ new.labeledStatementExportDeclarationNoCrash1(module=esnext).errors.txt +@@= skipped -0, +0 lines =@@ + labeledStatementExportDeclarationNoCrash1.ts(3,14): error TS1155: 'const' declarations must be initialized. ++labeledStatementExportDeclarationNoCrash1.ts(4,1): error TS1344: 'A label is not allowed here. + labeledStatementExportDeclarationNoCrash1.ts(5,1): error TS1184: Modifiers cannot appear here. + labeledStatementExportDeclarationNoCrash1.ts(5,14): error TS1155: 'const' declarations must be initialized. + + +-==== labeledStatementExportDeclarationNoCrash1.ts (3 errors) ==== ++==== labeledStatementExportDeclarationNoCrash1.ts (4 errors) ==== + // https://github.com/microsoft/TypeScript/issues/59372 + + export const box: string + ~~~ + !!! error TS1155: 'const' declarations must be initialized. + subTitle: ++ ~~~~~~~~ ++!!! error TS1344: 'A label is not allowed here. + export const title: string + ~~~~~~ + !!! error TS1184: Modifiers cannot appear here. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/labeledStatementExportDeclarationNoCrash1(module=system).errors.txt b/testdata/baselines/reference/submodule/conformance/labeledStatementExportDeclarationNoCrash1(module=system).errors.txt index c82821c21e..89400ea7ad 100644 --- a/testdata/baselines/reference/submodule/conformance/labeledStatementExportDeclarationNoCrash1(module=system).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/labeledStatementExportDeclarationNoCrash1(module=system).errors.txt @@ -1,15 +1,18 @@ labeledStatementExportDeclarationNoCrash1.ts(3,14): error TS1155: 'const' declarations must be initialized. +labeledStatementExportDeclarationNoCrash1.ts(4,1): error TS1344: 'A label is not allowed here. labeledStatementExportDeclarationNoCrash1.ts(5,1): error TS1184: Modifiers cannot appear here. labeledStatementExportDeclarationNoCrash1.ts(5,14): error TS1155: 'const' declarations must be initialized. -==== labeledStatementExportDeclarationNoCrash1.ts (3 errors) ==== +==== labeledStatementExportDeclarationNoCrash1.ts (4 errors) ==== // https://github.com/microsoft/TypeScript/issues/59372 export const box: string ~~~ !!! error TS1155: 'const' declarations must be initialized. subTitle: + ~~~~~~~~ +!!! error TS1344: 'A label is not allowed here. export const title: string ~~~~~~ !!! error TS1184: Modifiers cannot appear here. diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/blockScopedFunctionDeclarationInStrictModule.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/blockScopedFunctionDeclarationInStrictModule.errors.txt.diff new file mode 100644 index 0000000000..6373016809 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/blockScopedFunctionDeclarationInStrictModule.errors.txt.diff @@ -0,0 +1,16 @@ +--- old.blockScopedFunctionDeclarationInStrictModule.errors.txt ++++ new.blockScopedFunctionDeclarationInStrictModule.errors.txt +@@= skipped -0, +0 lines =@@ +-blockScopedFunctionDeclarationInStrictModule.ts(2,14): error TS1252: Function declarations are not allowed inside blocks in strict mode when targeting 'ES5'. Modules are automatically in strict mode. + blockScopedFunctionDeclarationInStrictModule.ts(6,10): error TS2304: Cannot find name 'foo'. + + +-==== blockScopedFunctionDeclarationInStrictModule.ts (2 errors) ==== ++==== blockScopedFunctionDeclarationInStrictModule.ts (1 errors) ==== + if (true) { + function foo() { } +- ~~~ +-!!! error TS1252: Function declarations are not allowed inside blocks in strict mode when targeting 'ES5'. Modules are automatically in strict mode. + foo(); // ok + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/labeledStatementExportDeclarationNoCrash1(module=system).errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/labeledStatementExportDeclarationNoCrash1(module=system).errors.txt.diff new file mode 100644 index 0000000000..5c22fe8e35 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/labeledStatementExportDeclarationNoCrash1(module=system).errors.txt.diff @@ -0,0 +1,22 @@ +--- old.labeledStatementExportDeclarationNoCrash1(module=system).errors.txt ++++ new.labeledStatementExportDeclarationNoCrash1(module=system).errors.txt +@@= skipped -0, +0 lines =@@ + labeledStatementExportDeclarationNoCrash1.ts(3,14): error TS1155: 'const' declarations must be initialized. ++labeledStatementExportDeclarationNoCrash1.ts(4,1): error TS1344: 'A label is not allowed here. + labeledStatementExportDeclarationNoCrash1.ts(5,1): error TS1184: Modifiers cannot appear here. + labeledStatementExportDeclarationNoCrash1.ts(5,14): error TS1155: 'const' declarations must be initialized. + + +-==== labeledStatementExportDeclarationNoCrash1.ts (3 errors) ==== ++==== labeledStatementExportDeclarationNoCrash1.ts (4 errors) ==== + // https://github.com/microsoft/TypeScript/issues/59372 + + export const box: string + ~~~ + !!! error TS1155: 'const' declarations must be initialized. + subTitle: ++ ~~~~~~~~ ++!!! error TS1344: 'A label is not allowed here. + export const title: string + ~~~~~~ + !!! error TS1184: Modifiers cannot appear here. \ No newline at end of file From e308412a5c0447372a873b89b5d4aaa5fe14fe44 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Mon, 16 Jun 2025 16:40:33 -0700 Subject: [PATCH 2/4] Update internal/scanner/scanner.go --- internal/scanner/scanner.go | 1 - 1 file changed, 1 deletion(-) diff --git a/internal/scanner/scanner.go b/internal/scanner/scanner.go index 1071b9da3a..7682fb266c 100644 --- a/internal/scanner/scanner.go +++ b/internal/scanner/scanner.go @@ -217,7 +217,6 @@ type ScannerState struct { type Scanner struct { text string - // TODO: remove this? unused except for (unimplemented) regex checking languageVariant core.LanguageVariant onError ErrorCallback skipTrivia bool From 10c9c2115d0570a89002ffb4b84ab7fdb4fa5905 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Mon, 16 Jun 2025 19:16:33 -0700 Subject: [PATCH 3/4] fmt --- internal/parser/parser_test.go | 6 ++---- internal/scanner/scanner.go | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/internal/parser/parser_test.go b/internal/parser/parser_test.go index 4231f13522..ca65f954d0 100644 --- a/internal/parser/parser_test.go +++ b/internal/parser/parser_test.go @@ -33,8 +33,7 @@ func BenchmarkParse(b *testing.B) { fileName := tspath.GetNormalizedAbsolutePath(f.Path(), "/") path := tspath.ToPath(fileName, "/", osvfs.FS().UseCaseSensitiveFileNames()) sourceText := f.ReadFile(b) - options := &core.SourceFileAffectingCompilerOptions{ - } + options := &core.SourceFileAffectingCompilerOptions{} for _, jsdoc := range jsdocModes { b.Run(jsdoc.name, func(b *testing.B) { @@ -133,8 +132,7 @@ func FuzzParser(f *testing.F) { return } - options := &core.SourceFileAffectingCompilerOptions{ - } + options := &core.SourceFileAffectingCompilerOptions{} ParseSourceFile(fileName, path, sourceText, options, nil, jsdocParsingMode) }) diff --git a/internal/scanner/scanner.go b/internal/scanner/scanner.go index 7682fb266c..c732e9b69b 100644 --- a/internal/scanner/scanner.go +++ b/internal/scanner/scanner.go @@ -216,7 +216,7 @@ type ScannerState struct { } type Scanner struct { - text string + text string languageVariant core.LanguageVariant onError ErrorCallback skipTrivia bool From e9c84b407b37de361779498baf84d1639243e56b Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Tue, 17 Jun 2025 10:18:54 -0700 Subject: [PATCH 4/4] fmt --- internal/astnav/tokens_test.go | 12 ++++++------ internal/format/api_test.go | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/internal/astnav/tokens_test.go b/internal/astnav/tokens_test.go index c8900dffb5..9c237dafee 100644 --- a/internal/astnav/tokens_test.go +++ b/internal/astnav/tokens_test.go @@ -53,8 +53,8 @@ func TestGetTokenAtPosition(t *testing.T) { } ` file := parser.ParseSourceFile(ast.SourceFileParseOptions{ - FileName: "/file.ts", - Path: "/file.ts", + FileName: "/file.ts", + Path: "/file.ts", }, fileText, core.ScriptKindTS) assert.Equal(t, astnav.GetTokenAtPosition(file, 0), astnav.GetTokenAtPosition(file, 0)) }) @@ -91,8 +91,8 @@ func baselineTokens(t *testing.T, testName string, includeEOF bool, getTSTokens } tsTokens := getTSTokens(string(fileText), positions) file := parser.ParseSourceFile(ast.SourceFileParseOptions{ - FileName: "/file.ts", - Path: "/file.ts", + FileName: "/file.ts", + Path: "/file.ts", }, string(fileText), core.ScriptKindTS) var output strings.Builder @@ -427,8 +427,8 @@ export function isAnyDirectorySeparator(charCode: number): boolean { t.Run(testCase.name, func(t *testing.T) { t.Parallel() file := parser.ParseSourceFile(ast.SourceFileParseOptions{ - FileName: "/file.ts", - Path: "/file.ts", + FileName: "/file.ts", + Path: "/file.ts", }, testCase.fileContent, core.ScriptKindTS) token := astnav.FindPrecedingToken(file, testCase.position) assert.Equal(t, token.Kind, testCase.expectedKind) diff --git a/internal/format/api_test.go b/internal/format/api_test.go index 6e6a296985..62e87898a8 100644 --- a/internal/format/api_test.go +++ b/internal/format/api_test.go @@ -56,8 +56,8 @@ func TestFormat(t *testing.T) { assert.NilError(t, err) text := string(fileContent) sourceFile := parser.ParseSourceFile(ast.SourceFileParseOptions{ - FileName: "/checker.ts", - Path: "/checker.ts", + FileName: "/checker.ts", + Path: "/checker.ts", }, text, core.ScriptKindTS) ast.SetParentInChildren(sourceFile.AsNode()) edits := format.FormatDocument(ctx, sourceFile) @@ -86,8 +86,8 @@ func BenchmarkFormat(b *testing.B) { assert.NilError(b, err) text := string(fileContent) sourceFile := parser.ParseSourceFile(ast.SourceFileParseOptions{ - FileName: "/checker.ts", - Path: "/checker.ts", + FileName: "/checker.ts", + Path: "/checker.ts", }, text, core.ScriptKindTS) ast.SetParentInChildren(sourceFile.AsNode())