mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-14 19:16:17 -06:00
Co-authored-by: Oleksandr T <oleksandr.tarasiuk@outlook.com>
This commit is contained in:
parent
c4108b6db2
commit
a0a3a79882
@ -2638,7 +2638,7 @@ namespace Parser {
|
||||
function createIdentifier(isIdentifier: boolean, diagnosticMessage?: DiagnosticMessage, privateIdentifierDiagnosticMessage?: DiagnosticMessage): Identifier {
|
||||
if (isIdentifier) {
|
||||
identifierCount++;
|
||||
const pos = getNodePos();
|
||||
const pos = scanner.hasLeadingAsterisks() ? scanner.getTokenStart() : getNodePos();
|
||||
// Store original token kind if it is not just an Identifier so we can report appropriate error later in type checker
|
||||
const originalKeywordKind = token();
|
||||
const text = internIdentifier(scanner.getTokenValue());
|
||||
|
||||
@ -112,6 +112,8 @@ export interface Scanner {
|
||||
resetTokenState(pos: number): void;
|
||||
/** @internal */
|
||||
setSkipJsDocLeadingAsterisks(skip: boolean): void;
|
||||
/** @internal */
|
||||
hasLeadingAsterisks(): boolean;
|
||||
// Invokes the provided callback then unconditionally restores the scanner to the state it
|
||||
// was in immediately prior to invoking the callback. The result of invoking the callback
|
||||
// is returned from this function.
|
||||
@ -1042,6 +1044,7 @@ export function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean
|
||||
|
||||
var commentDirectives: CommentDirective[] | undefined;
|
||||
var skipJsDocLeadingAsterisks = 0;
|
||||
var asteriskSeen = false;
|
||||
|
||||
var scriptKind = ScriptKind.Unknown;
|
||||
var jsDocParsingMode = JSDocParsingMode.ParseAll;
|
||||
@ -1096,6 +1099,7 @@ export function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean
|
||||
resetTokenState,
|
||||
setTextPos: resetTokenState,
|
||||
setSkipJsDocLeadingAsterisks,
|
||||
hasLeadingAsterisks,
|
||||
tryScan,
|
||||
lookAhead,
|
||||
scanRange,
|
||||
@ -1877,7 +1881,7 @@ export function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean
|
||||
function scan(): SyntaxKind {
|
||||
fullStartPos = pos;
|
||||
tokenFlags = TokenFlags.None;
|
||||
let asteriskSeen = false;
|
||||
asteriskSeen = false;
|
||||
while (true) {
|
||||
tokenStart = pos;
|
||||
if (pos >= end) {
|
||||
@ -4004,6 +4008,10 @@ export function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean
|
||||
function setSkipJsDocLeadingAsterisks(skip: boolean) {
|
||||
skipJsDocLeadingAsterisks += skip ? 1 : -1;
|
||||
}
|
||||
|
||||
function hasLeadingAsterisks() {
|
||||
return asteriskSeen;
|
||||
}
|
||||
}
|
||||
|
||||
function codePointAt(s: string, i: number): number {
|
||||
|
||||
34
tests/baselines/reference/importTag18.js
Normal file
34
tests/baselines/reference/importTag18.js
Normal file
@ -0,0 +1,34 @@
|
||||
//// [tests/cases/conformance/jsdoc/importTag18.ts] ////
|
||||
|
||||
//// [a.ts]
|
||||
export interface Foo {}
|
||||
|
||||
//// [b.js]
|
||||
/**
|
||||
* @import {
|
||||
* Foo
|
||||
* } from "./a"
|
||||
*/
|
||||
|
||||
/**
|
||||
* @param {Foo} a
|
||||
*/
|
||||
export function foo(a) {}
|
||||
|
||||
|
||||
|
||||
|
||||
//// [a.d.ts]
|
||||
export interface Foo {
|
||||
}
|
||||
//// [b.d.ts]
|
||||
/**
|
||||
* @import {
|
||||
* Foo
|
||||
* } from "./a"
|
||||
*/
|
||||
/**
|
||||
* @param {Foo} a
|
||||
*/
|
||||
export function foo(a: Foo): void;
|
||||
import type { Foo } from "./a";
|
||||
20
tests/baselines/reference/importTag18.symbols
Normal file
20
tests/baselines/reference/importTag18.symbols
Normal file
@ -0,0 +1,20 @@
|
||||
//// [tests/cases/conformance/jsdoc/importTag18.ts] ////
|
||||
|
||||
=== a.ts ===
|
||||
export interface Foo {}
|
||||
>Foo : Symbol(Foo, Decl(a.ts, 0, 0))
|
||||
|
||||
=== b.js ===
|
||||
/**
|
||||
* @import {
|
||||
* Foo
|
||||
* } from "./a"
|
||||
*/
|
||||
|
||||
/**
|
||||
* @param {Foo} a
|
||||
*/
|
||||
export function foo(a) {}
|
||||
>foo : Symbol(foo, Decl(b.js, 0, 0))
|
||||
>a : Symbol(a, Decl(b.js, 9, 20))
|
||||
|
||||
22
tests/baselines/reference/importTag18.types
Normal file
22
tests/baselines/reference/importTag18.types
Normal file
@ -0,0 +1,22 @@
|
||||
//// [tests/cases/conformance/jsdoc/importTag18.ts] ////
|
||||
|
||||
=== a.ts ===
|
||||
|
||||
export interface Foo {}
|
||||
|
||||
=== b.js ===
|
||||
/**
|
||||
* @import {
|
||||
* Foo
|
||||
* } from "./a"
|
||||
*/
|
||||
|
||||
/**
|
||||
* @param {Foo} a
|
||||
*/
|
||||
export function foo(a) {}
|
||||
>foo : (a: Foo) => void
|
||||
> : ^ ^^^^^^^^^^^^^^
|
||||
>a : Foo
|
||||
> : ^^^
|
||||
|
||||
@ -25,10 +25,10 @@ export interface B {
|
||||
* @param { B } b
|
||||
*/
|
||||
function f(a, b) {}
|
||||
>f : (a: * A, b: * B) => void
|
||||
> : ^ ^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^
|
||||
>a : * A
|
||||
> : ^^^^^^^
|
||||
>b : * B
|
||||
> : ^^^^^^^
|
||||
>f : (a: A, b: B) => void
|
||||
> : ^ ^^^^^ ^^^^^^^^^^^^
|
||||
>a : A
|
||||
> : ^
|
||||
>b : B
|
||||
> : ^
|
||||
|
||||
|
||||
@ -24,10 +24,10 @@ export interface B {
|
||||
* @param { B } b
|
||||
*/
|
||||
function f(a, b) {}
|
||||
>f : (a: * A, b: * B) => void
|
||||
> : ^ ^^^^^^^ ^^^^^^^^^^^^^^
|
||||
>a : * A
|
||||
> : ^^^
|
||||
>b : * B
|
||||
> : ^^^
|
||||
>f : (a: A, b: B) => void
|
||||
> : ^ ^^^^^ ^^^^^^^^^^^^
|
||||
>a : A
|
||||
> : ^
|
||||
>b : B
|
||||
> : ^
|
||||
|
||||
|
||||
19
tests/cases/conformance/jsdoc/importTag18.ts
Normal file
19
tests/cases/conformance/jsdoc/importTag18.ts
Normal file
@ -0,0 +1,19 @@
|
||||
// @declaration: true
|
||||
// @emitDeclarationOnly: true
|
||||
// @checkJs: true
|
||||
// @allowJs: true
|
||||
|
||||
// @filename: a.ts
|
||||
export interface Foo {}
|
||||
|
||||
// @filename: b.js
|
||||
/**
|
||||
* @import {
|
||||
* Foo
|
||||
* } from "./a"
|
||||
*/
|
||||
|
||||
/**
|
||||
* @param {Foo} a
|
||||
*/
|
||||
export function foo(a) {}
|
||||
Loading…
x
Reference in New Issue
Block a user