Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Bug: strictNonNullAssertions adds !!!!!!!!!!!!!!!!!!!!! #1517

Open
3 tasks done
rubiesonthesky opened this issue Apr 3, 2024 · 1 comment
Open
3 tasks done
Labels
status: needs reproduction The issue was filed with a missing or incomplete reproduction, and it can't be reproduced locally. type: bug Something isn't working :( 🐛

Comments

@rubiesonthesky
Copy link
Collaborator

Bug Report Checklist

  • I have tried restarting my IDE and the issue persists.
  • I have pulled the latest main branch of the repository.
  • I have searched for related issues and found none that matched my issue.

Expected

There should not be reason to add ! here. attributeTypesAndRequirements should be always Map

const visitReactComponentNode = (
	node: ReactComponentNode,
	request: FileMutationsRequest,
) => {
  // ...
	// Find all types of props later passed to the node
	const attributeTypesAndRequirements = collectComponentAttributeTypes(
		request,
		node,
	);
        // ! ts language server says `attributeTypes` is `attributeTypes: Map<string, ts.Type[]>`, so it should not be undefined
	if (!attributeTypesAndRequirements?.attributeTypes.size) {
		return undefined;
	}
  // ...
};

Actual

const visitReactComponentNode = (
	node: ReactComponentNode,
	request: FileMutationsRequest,
) => {
  // ...
	// Find all types of props later passed to the node
	const attributeTypesAndRequirements = collectComponentAttributeTypes(
		request,
		node,
	);
        // ! ts language server says `attributeTypes` is `attributeTypes: Map<string, ts.Type[]>`, so it should not be undefined
	if (!attributeTypesAndRequirements?.attributeTypes!!!!!!!!!!!!!!!!!!!!!.size) {
		return undefined;
	}
  // ...
};

Additional Info

typestat.json

[
    {
        "fixes": {
            "strictNonNullAssertions": true
        },
        "include": [
            "src/**/*.{ts,tsx}"
        ],
        "projectPath": "./tsconfig.json",
        "types": {
            "strictNullChecks": true
        }
    }
]

tsconfig

{
	"compilerOptions": {
		"declaration": true,
		"declarationMap": true,
		"esModuleInterop": true,
		"module": "NodeNext",
		"moduleResolution": "NodeNext",
		"noEmit": true,
		"outDir": "lib",
		"resolveJsonModule": true,
		"skipLibCheck": true,
		"sourceMap": true,
		"strict": true,
		"target": "ES2022"
	},
	"include": ["src", "test/*.ts"]
}
@rubiesonthesky rubiesonthesky added the type: bug Something isn't working :( 🐛 label Apr 3, 2024
@rubiesonthesky
Copy link
Collaborator Author

Simple case of this does not work in test case. So either this is fixed or this is more complex problem.

Test with next version of typestat. (This was discovered with version 0.7.3)

@rubiesonthesky rubiesonthesky added the status: needs reproduction The issue was filed with a missing or incomplete reproduction, and it can't be reproduced locally. label Apr 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs reproduction The issue was filed with a missing or incomplete reproduction, and it can't be reproduced locally. type: bug Something isn't working :( 🐛
Projects
None yet
Development

No branches or pull requests

1 participant