microsoft / microsoft/TypeScript
An error occurs when passing the SourceFile node to getTypeAtLocation.
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Go
- Estrellas
- 111k
- Forks
- 14.3k
- Merge medio
- 2 d 4 h
- PR fusionados (30 d)
- 132
Descripción
### 🔎 Search Terms
getTypeAtLocation && SourceFile
### 🕗 Version & Regression Information
- This changed between versions ______ and _______
- This changed in commit or PR _______
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about _________
- I was unable to test this on prior versions because _______
### ⏯ Playground Link
_No response_
### 💻 Code
```ts
//ModuleA
export let namedOther = null;
//ModuleB
import * as testNs from './ModuleA';
export { testNs };
```
### 🙁 Actual behavior
In the statement 'export { testNs }', call getTypeAtLocation on 'testNs' to retrieve its type.
### 🙂 Expected behavior
It is expected to obtain the returned type, whether the result is errorType or another type, but in reality, an error 'Cannot read properties of undefined (reading 'kind')' will be reported in getTypeAtLocation#getTypeOfNode#isDeclarationNameOrImportPropertyName.
### Additional information about the issue
The `getTypeOfNode` function supports passing a `SourceFile` node, but if the condition `isExternalModule` is not met, the `SourceFile` node will proceed to execute further.
When executing the `isDeclarationNameOrImportPropertyName` method, the passed node is still the `SourceFile` node, and an error is directly reported at `name.parent`.
_No response_
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza reproduciendo el ejemplo proporcionado de ModuleA/ModuleB y sigue getTypeAtLocation a través de getTypeOfNode, isExternalModule e isDeclarationNameOrImportPropertyName. Verifica que pasar el nodo SourceFile ya no provoque el error name.parent y que getTypeAtLocation devuelva un tipo o errorType, como se espera.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- typescript
- Área
- compilers
- Tipo de issue
- Error
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100