File tree Expand file tree Collapse file tree 4 files changed +39
-3
lines changed Expand file tree Collapse file tree 4 files changed +39
-3
lines changed Original file line number Diff line number Diff line change @@ -2744,11 +2744,11 @@ namespace ts {
27442744 const node = getParseTreeNode ( contextNode ) ;
27452745 const isSimilarNode = node && node . kind === contextNode . kind ;
27462746 const startPos = pos ;
2747- if ( isSimilarNode ) {
2748- pos = skipTrivia ( currentSourceFile ! . text , pos ) ;
2747+ if ( isSimilarNode && currentSourceFile ) {
2748+ pos = skipTrivia ( currentSourceFile . text , pos ) ;
27492749 }
27502750 if ( emitLeadingCommentsOfPosition && isSimilarNode && contextNode . pos !== startPos ) {
2751- const needsIndent = indentLeading && ! positionsAreOnSameLine ( startPos , pos , currentSourceFile ! ) ;
2751+ const needsIndent = indentLeading && currentSourceFile && ! positionsAreOnSameLine ( startPos , pos , currentSourceFile ) ;
27522752 if ( needsIndent ) {
27532753 increaseIndent ( ) ;
27542754 }
Original file line number Diff line number Diff line change 1+ tests/cases/compiler/crashInEmitTokenWithComment.ts(5,4): error TS2345: Argument of type '({ [foo.bar]: c }: {}) => any' is not assignable to parameter of type 'string'.
2+ tests/cases/compiler/crashInEmitTokenWithComment.ts(5,7): error TS2537: Type '{}' has no matching index signature for type 'string'.
3+
4+
5+ ==== tests/cases/compiler/crashInEmitTokenWithComment.ts (2 errors) ====
6+ // GH#32358
7+ const fn = (param: string) => undefined;
8+
9+ const foo = {bar: 'a'};
10+ fn(({[foo.bar]: c}) => undefined);
11+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
12+ !!! error TS2345: Argument of type '({ [foo.bar]: c }: {}) => any' is not assignable to parameter of type 'string'.
13+ ~~~~~~~
14+ !!! error TS2537: Type '{}' has no matching index signature for type 'string'.
Original file line number Diff line number Diff line change 1+ //// [crashInEmitTokenWithComment.ts]
2+ // GH#32358
3+ const fn = ( param : string ) => undefined ;
4+
5+ const foo = { bar : 'a' } ;
6+ fn ( ( { [ foo . bar ] : c } ) => undefined ) ;
7+
8+ //// [crashInEmitTokenWithComment.js]
9+ // GH#32358
10+ var fn = function ( param ) { return undefined ; } ;
11+ var foo = { bar : 'a' } ;
12+ fn ( function ( _a ) {
13+ var _b = foo . bar , c = _a [ _b ] ;
14+ return undefined ;
15+ } ) ;
Original file line number Diff line number Diff line change 1+ // @noTypesAndSymbols : true
2+
3+ // GH#32358
4+ const fn = ( param : string ) => undefined ;
5+
6+ const foo = { bar : 'a' } ;
7+ fn ( ( { [ foo . bar ] : c } ) => undefined ) ;
You can’t perform that action at this time.
0 commit comments