-
-
Notifications
You must be signed in to change notification settings - Fork 223
Closed
Labels
FixedFixed in master branch. Pending production release.Fixed in master branch. Pending production release.
Description
Say you have the following component (it's using TypeScript, of course):
MyComponent.svelte:
<script lang="ts">
export let label: string;
</script>
...As you can see, the label prop is required, I have not supplied a default value and thus it's considered a required prop.
Now, if I have strictNullChecks set to true in my tsconfig.json file, I expect a required component prop like label in this case to not be able to receive null or undefined unless I explicitly specify that in their type.
tsconfig.json:
"compilerOptions": {
"strictNullChecks": true
}However, Svelte appears to make the type of the label prop string | undefined behind the scenes, and that means the consumer of this component could pass undefined as the value of label, which obviously defeats the whole purpose of enabling strictNullChecks in the first place.
<MyComponent label={undefined} /> <!-- No error! Even though "strictNullChecks" is "true" + the type of "label" is "string" -->aahmadi458, araxemy, PatrickG and aradalvand
Metadata
Metadata
Assignees
Labels
FixedFixed in master branch. Pending production release.Fixed in master branch. Pending production release.